#include "base.h"
#include "stack"

class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        int sum=0;
        int max=INT_MIN;
        for (auto a:nums) {
            sum=max(a,sum+a);
            if(sum>max){
                max=sum;
            }
        }
        return max;
    }
};